from unittest import TestCase
from replacer import _Replacer
class TestReplacer(TestCase):
    def testRemoveImagesTail(self):
        replacer = _Replacer()
               
        demies = [0,1,2,3,4,5,6,7,8]
        for i in demies:
            replacer.setImage(i)
        
        #tail starts behind boundries
        self.assertRaises(IndexError,replacer.removeImagesTail, 9)
        
        #tail starts at last element
        replacer.removeImagesTail(8)
        self.assertEquals(replacer.imageWithChanges, [0,1,2,3,4,5,6,7])
        
        #tail starts at a middle element
        replacer.removeImagesTail(5)
        self.assertEquals(replacer.imageWithChanges, [0,1,2,3,4])
        
        #tail starts at first element
        replacer.removeImagesTail(0)
        self.assertEquals(replacer.imageWithChanges, [])
        
        #size 0
        self.assertRaises(IndexError,replacer.removeImagesTail, 4)
        
        